﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing.skinbuilder {
    import flash.display.*;
    import org.aswing.geom.*;

    public class ButtonStateObject extends Sprite {

        protected var defaultImage:DisplayObject;
        protected var pressedImage:DisplayObject;
        protected var pressedSelectedImage:DisplayObject;
        protected var disabledImage:DisplayObject;
        protected var selectedImage:DisplayObject;
        protected var disabledSelectedImage:DisplayObject;
        protected var rolloverImage:DisplayObject;
        protected var rolloverSelectedImage:DisplayObject;
        protected var defaultButtonImage:DisplayObject;
        protected var enabled:Boolean = true;
        protected var pressed:Boolean = false;
        protected var selected:Boolean = false;
        protected var rollovered:Boolean = false;
        protected var defaultButton:Boolean = false;
        protected var lastViewedImage:DisplayObject;

        public function ButtonStateObject(){
            name = "ButtonStateObject";
            mouseEnabled = false;
            tabEnabled = false;
        }
        public function updateRepresent(_arg1:IntRectangle=null):void{
            var _local3:DisplayObject;
            var _local2:DisplayObject = this.defaultImage;
            if (!this.enabled){
                if (((this.selected) && (this.disabledSelectedImage))){
                    _local3 = this.disabledSelectedImage;
                } else {
                    _local3 = this.disabledImage;
                };
            } else {
                if (this.pressed){
                    if (((this.selected) && (this.pressedSelectedImage))){
                        _local3 = this.pressedSelectedImage;
                    } else {
                        _local3 = this.pressedImage;
                    };
                } else {
                    if (this.rollovered){
                        if (((this.selected) && (this.rolloverSelectedImage))){
                            _local3 = this.rolloverSelectedImage;
                        } else {
                            _local3 = this.rolloverImage;
                        };
                    } else {
                        if (this.selected){
                            _local3 = this.selectedImage;
                        } else {
                            if (this.defaultButton){
                                _local3 = this.defaultButtonImage;
                            };
                        };
                    };
                };
            };
            if (_local3 != null){
                _local2 = _local3;
            };
            if (_local2 != this.lastViewedImage){
                if (this.lastViewedImage){
                    this.lastViewedImage.visible = false;
                };
                if (_local2){
                    _local2.visible = true;
                };
                this.lastViewedImage = _local2;
            };
            if (_arg1 != null){
                if (_local2){
                    _local2.width = _arg1.width;
                    _local2.height = _arg1.height;
                };
                this.x = _arg1.x;
                this.y = _arg1.y;
            };
        }
        public function setEnabled(_arg1:Boolean):void{
            this.enabled = _arg1;
        }
        public function setPressed(_arg1:Boolean):void{
            this.pressed = _arg1;
        }
        public function setSelected(_arg1:Boolean):void{
            this.selected = _arg1;
        }
        public function setRollovered(_arg1:Boolean):void{
            this.rollovered = _arg1;
        }
        public function setDefaultButton(_arg1:Boolean):void{
            this.defaultButton = _arg1;
        }
        protected function checkAsset(_arg1:DisplayObject):void{
            if (((!((_arg1 == null))) && (contains(_arg1)))){
                throw (new Error("You are set a already exists asset!"));
            };
        }
        override public function addChild(_arg1:DisplayObject):DisplayObject{
            if (_arg1 != null){
                _arg1.visible = false;
                return (super.addChild(_arg1));
            };
            return (null);
        }
        public function setDefaultButtonImage(_arg1:DisplayObject):void{
            this.checkAsset(this.defaultButtonImage);
            this.defaultButtonImage = _arg1;
            this.addChild(_arg1);
        }
        public function setDefaultImage(_arg1:DisplayObject):void{
            this.checkAsset(this.defaultImage);
            this.defaultImage = _arg1;
            this.addChild(_arg1);
        }
        public function setPressedImage(_arg1:DisplayObject):void{
            this.checkAsset(this.pressedImage);
            this.pressedImage = _arg1;
            this.addChild(_arg1);
        }
        public function setPressedSelectedImage(_arg1:DisplayObject):void{
            this.checkAsset(this.pressedSelectedImage);
            this.pressedSelectedImage = _arg1;
            this.addChild(_arg1);
        }
        public function setDisabledImage(_arg1:DisplayObject):void{
            this.checkAsset(this.disabledImage);
            this.disabledImage = _arg1;
            this.addChild(_arg1);
        }
        public function setSelectedImage(_arg1:DisplayObject):void{
            this.checkAsset(this.selectedImage);
            this.selectedImage = _arg1;
            this.addChild(_arg1);
        }
        public function setDisabledSelectedImage(_arg1:DisplayObject):void{
            this.checkAsset(this.disabledSelectedImage);
            this.disabledSelectedImage = _arg1;
            this.addChild(_arg1);
        }
        public function setRolloverImage(_arg1:DisplayObject):void{
            this.checkAsset(this.rolloverImage);
            this.rolloverImage = _arg1;
            this.addChild(_arg1);
        }
        public function setRolloverSelectedImage(_arg1:DisplayObject):void{
            this.checkAsset(this.rolloverSelectedImage);
            this.rolloverSelectedImage = _arg1;
            this.addChild(_arg1);
        }

    }
}//package org.aswing.skinbuilder 
